<?php

namespace Admin\Controller;

class TopnavController extends CommonController {


	  public function index() {
    	try {

    		$api = D('api')->cache(true)->where('status=1')->select();

    		foreach ($api as $key => $val) {
    			switch ($val['platform']) {
    				case 0:
				    		//c6
							Vendor('C6.C6Api');
							$c6 = new \C6Api($val['api_address']);
							$this->assign('pending_work_list',$c6->getPendingWorkList());
							$this->assign('flat_info_waiting',$c6->getFlatInfoWaitingList());
				  			$this->assign('c6_login_url',$c6->getLoginUrl());
    					break;
					case 1:
							//论坛
							Vendor('Forum.ForumApi');
							$forum = new \ForumApi($val['api_address']);
							$this->assign('forumMessageList',$forum->getForumMessageList());
							$this->assign('forum_login_url',$forum->getLoginUrl());
						break;
					case 2:
							//获取企业邮箱信息
							$username = getUserName();
							Vendor('exmail.ExmailApi');
				        	$exmial =   new \ExmailApi($val['account']);
				        	$mailData = $exmial->getMaillLists($username);
							$this->assign('expmailData',$mailData->List);
							$this->assign('exmail_login_url',$exmial->getLoginUrl($username));

						break;
    			}
    		}

	    	$this->display();

    	} catch (Exception $e) {
    		$this->error($e->getMessage());
    	}
    }

    
}